//
//  CMIInfoAlertView.m
//  ejiaqingAlertView
//
//  Created by 杨攀 on 16/10/13.
//  Copyright © 2016年 CMIG. All rights reserved.
//

#import "CMIInfoAlertView.h"
#import <Masonry.h>
#import "InfoTopView.h"
#import "InfoMainView.h"
#import "InfoBottomView.h"
#define Main_Screen_Width [[UIScreen mainScreen] bounds].size.width
#define Main_Screen_Height [[UIScreen mainScreen] bounds].size.height

@interface CMIInfoAlertView ()

/**<#type#>*/
@property (nonatomic, copy) buyComplationBlock buyBlock;
/**<#type#>*/
@property (nonatomic, copy) payComplationBlock payBlock;
/** 背景 */
@property (nonatomic,strong) UIView *bgView;
/** titleView */
@property (nonatomic,strong) InfoTopView *topView;
/** mainView */
@property (nonatomic,strong) InfoMainView *mainView;
/** bottomView */
@property (nonatomic,strong) InfoBottomView *bottomView;
/** container */
@property (nonatomic,strong) UIView *containView;
@end

@implementation CMIInfoAlertView

- (instancetype)initWithBuyBlock:(buyComplationBlock)buyBlock payBlock:(payComplationBlock)payBlock
{
    if (self = [super initWithFrame:CGRectMake(0, 0, Main_Screen_Width, Main_Screen_Height)]) {
        _buyBlock = buyBlock;
        _payBlock = payBlock;
        
        [self initUI];
    }
    return self;
}
- (void)initUI
{
    self.bgView = [UIView new];
    [self.bgView setBackgroundColor:[UIColor blackColor]];
    [self addSubview:self.bgView];
    
    self.containView = [UIView new];
    [self.containView setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:self.containView];
    
    self.topView = [InfoTopView new];
    self.topView.titleName = @"联华ok卡";
    [self.containView addSubview:self.topView];
    
    self.mainView = [InfoMainView new];
//    [self.mainView setBackgroundColor:[UIColor brownColor]];
    NSArray *arr = @[@"平层",@"复室",@"别墅",@"平层",@"复室",@"别墅",@"平层",@"复室",@"别墅"];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"ejiaqin.plist" ofType:nil];
    NSArray *arrays = [NSArray arrayWithContentsOfFile:path];
//    [self.mainView getInfoMoreOfArrary:arrays];
    self.mainView.titleName = @"室内类型";
    self.mainView.count = arrays.count;
    [self.mainView getInfoOfArray:arrays state:CMIInfoStrings];
    [self addSubview:self.mainView];
    
    self.bottomView = [InfoBottomView new];
    [self.bottomView setBackgroundColor:[UIColor whiteColor]];
    [self.containView addSubview:self.bottomView];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self).insets(UIEdgeInsetsZero);
    }];
    
    [self.containView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.bottom.equalTo(self);
        make.height.equalTo(@406);
    }];
    
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.top.equalTo(self.containView);
        make.height.equalTo(@55);
    }];
    
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.bottom.equalTo(self.containView);
        make.height.equalTo(@75);
    }];
    
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.mas_bottom);
        make.right.left.equalTo(self.containView);
        make.bottom.equalTo(self.bottomView.mas_top);
    }];
    
    
    
}

@end
